package com.demo01_video.bean;

import com.demo01_video.uitl.MinioUtil;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import com.user_service.util.SnowflakeIdGenerator;

import java.util.Date;

@Entity
@Table(name = "video")
@Data
public class Video {
    @Id
    private Long id;
    private String title;
    private String videoUrl;
    private String coverUrl;
    private Long authorId;
    private Integer status=0;//状态：0-待转码，1-转码中，2-转码成功，3-转码失败
    private Long likeCount=0L;
    
    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_at")
    private Date createdAt;
    
    @PrePersist
    public void prePersist() {
        if (this.id == null) {
            // 使用Snowflake算法生成ID
            // 注意：在实际生产环境中，应该通过依赖注入获取对应的ID生成器
            SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(2);
            this.id = idGenerator.nextId();
        }
    }
}